import { 
  defineConfig,
  loadEnv
} from "vite";
import vue from "@vitejs/plugin-vue";
import eslint from "vite-plugin-eslint";
// import cdnImport from "vite-plugin-cdn-import";

export default (async ({ mode }) => {
  const env = await loadEnv(mode, process.cwd());
  const basePath = env.VITE_APP_STATIC_URL;
  return defineConfig({
    base: basePath,
    plugins: [
      vue(),
      eslint({
        include: ["src/**/*.js", "src/**/*.vue", "src/*.js", "src/*.vue"]
      }),
      // cdnImport({
      //   include: ["**/*.vue", "**/*.js"],
      //   exclude: []
      // })
    ],
    resolve: {
      alias: {
        "@": "/src"
      }
    },
    server: {
      open: false,
      proxy: {
        "https://auth-dev.weistream.com/": {
          target: "https://auth-dev.weistream.com/",
          changeOrigin: true,
          ws: true
        },
        "https://admin-dev.weistream.com/": {
          target: "https://admin-dev.weistream.com/",
          changeOrigin: true,
          ws: true
        },
        "https://live-dev.weistream.com/": {
          target: "https://live-dev.weistream.com/",
          changeOrigin: true,
          ws: true
        }
      }
    }
  });
});
